#******************************************************************************#
#                         Class  : ExampleModule                               #
#******************************************************************************#

# Refer http://perldoc.perl.org/Exporter.html#Good-Practices

package ExampleModule;

use strict;
use warnings;

#Import symbols defined in Exporter::(@EXPORT) into current symbol table during compile-time.
#The user of this module will call Exporter::import() method to import symbols defined in
#current @EXPORT into their symbol table.
#The Exporter module implements an import method which allows a module to export functions and
#variables to its users' namespaces. Many modules use Exporter rather than implementing their
#own import method because Exporter provides a highly flexible interface, with an implementation
#optimised for the common case. Perl automatically calls the import method when processing a use
#statement for a module. Modules and use are documented in perlfunc and perlmod. Understanding
#the concept of modules and how the use statement operates is important to understanding the Exporter
use Exporter;

#Current class(module) is a subclass of Exporter (is a). If methods calling can't be found in
#current class, it will be searched in Exporter (its father class). Exporter::import() is used.
our @ISA = qw(Exporter);

# (1) The arrays @EXPORT and @EXPORT_OK in a module hold lists of symbols that are going to be exported
# into the users name space by default, or which they can request to be exported, respectively.
# The symbols can represent functions, scalars, arrays, hashes, or typeglobs.
# The symbols must be given by full name with the exception that the ampersand in front of a function
# is optional.
# (2) Prefer @EXPORT_OK than @EXPORT.
# (3) As a general rule, if the module is trying to be object oriented then export nothing. If it's 
# just a collection of functions then @EXPORT_OK anything but use @EXPORT with caution. 
our @EXPORT    = qw($ourVar @ourArray printPgSymbol);
our @EXPORT_OK = qw($ourVar @ourArray printPgSymbol);

# When using Exporter with the standard strict and warnings pragmas, the our keyword is needed to declare
# the package variables @EXPORT_OK , @EXPORT , @ISA , etc.
our $ourVar = 300;
our @ourArray = qw ( 111 222 );

sub printPgSymbol
{
	while ( my ( $key, $value ) = each(%ExampleModule::) )
	{

		# Look at the symbol table of this package
		print "$key:\t\t$value\n";
	}
}
